home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
JCSM Shareware Collection 1993 November
/
JCSM Shareware Collection - 1993-11.iso
/
cl760
/
garfforj.lzh
/
GRAPH.DOC
< prev
next >
Wrap
Text File
|
1991-04-08
|
39KB
|
1,030 lines
Graph for Fortran v3.0
Graph plotting on dot matrix printers
=======================================
********************************************************************
SHAREWARE NOTICE Copyright (C) D.I. Hoyer, 1990/1991.
==================
If you find these Fortran subroutines useful, please register
by sending US$35-00 or Aus$40-00 to the address below :-
David I Hoyer
P.O. Box 1743
Macquarie Centre NSW 2113
AUSTRALIA
This subroutine library is a shareware product. Copies of the
original unmodified programs and manual on disk may be made
and distributed, as long as they are not charged for. You may
not modify the source code or manual except for your personal
use. Registrants will receive a free update.
*******************************************************************
No responsibility is accepted for any errors in this software,
or for any loss or damage resulting from using it.
*******************************************************************
Page 2
C O N T E N T S
=================
Page
0. Shareware notice . . . . . . . . . . . . . . 1
1. Introduction . . . . . . . . . . . . . . . . 3
2. Description of disk contents . . . . . . . . . . 4
3. Some quick demonstrations . . . . . . . . . . . 5
4. Using GRAPH to plot graphs from a data file . . . . . 6
a) Plotting the demo graphs supplied . . . . . . . 6
b) Plotting your own graphs . . . . . . . . . 6
c) Data file specifications for GRAPH.for . . . . . 7
5. Using the GRAPHLIB subroutines to get your own . . . . 9
programs to plot graphs
6. Limitations . . . . . . . . . . . . . . . . 10
a) Graph size & Memory . . . . . . . . . . . 10
b) Function parameters . . . . . . . . . . . 10
Appendix A. Definition of Fortran names used . . . . . . 11
Appendix B. Symbols and line types. . . . . . . . . . 14
Appendix C. Sample list of standard user-defined functions . 15
Appendix D. A sample data file for use with GRAPH . . . . 18
Appendix E. Changes from earlier versions . . . . . . . 22
Page 3
Graph plotting on dot matrix printers
=======================================
1. Introduction
=================
Print out this manual by typing:
copy graph.doc prn
This collection of Fortran subroutines will make it simple for
you to plot high quality scientific and engineering graphs on
dot matrix printers which have the ability to print graphics.
These subroutines can easily be incorporated into any Fortran
program, so that your own programs can automatically print
high resolution graphs as part of the program output. Also
included is a sample main program to illustrate the use of the
subroutines. This sample program works as a stand-alone graph
plotter for plotting graphs from a data file. So, as an
alternative to incorporating the graph plotting subroutines
into your own programs, you could instead get your program to
simply write a suitable data file to disk for plotting out
later, using the sample main program supplied (GRAPH.for).
Some of the features available are :
* high or low resolution options,
* graph can be plotted vertically or horizontally on the page,
* linear or logarithmic axes, with labelling of axes,
* overlaying grid lines on the graph, in various line styles,
* drawing lines in different styles (solid, dotted etc.),
* plotting points, with a large range of symbols to choose from,
* joining points with straight lines or a cubic spline,
* plotting user-defined functions,
* passing a list of parameters to the user-defined functions,
* placing text of different sizes and orientations on the graph,
* clearing an area of the graph, with optional border,
* automatic generation of legend tables to describe each curve,
* variable size and spacing of axis labels.
Read through this manual and print out all the demonstration
graphs before using the programs for your own applications.
That way you will be more familiar with the capabilities of
the programs.
Page 4
2. Description of disk contents
=================================
Your disk should contain the following files :-
README .exe Program for browsing through documents & manuals.
README .doc Text document with a description of the overall
use of the programs, plus a brief description of
each file.
REGIST .doc Registration form, and other information.
GRF .bat Sample batch file for executing GRAPH with a
data file.
GRAPH .doc User's manual.
GRAPH .for Sample main program for plotting graphs on dot
matrix printers, from data files.
GRAPHLIB.for Subroutine library of graph plotting
procedures for plotting on dot matrix printers.
GRAPHFNS.for Function segment containing user-defined
functions.
GRAPH .nnn Sample data files to use with GRF.bat
(nnn is a number 001 to 999) :-
GRAPH.001 General graph demo (vertical and Hi-res).
GRAPH.002 Same as .001, but horizontal and Lo-res format.
GRAPH.003 Graph of several standard functions.
GRAPH.004 Demo of text, graph symbols and line styles.
GRAPH.005 Variation of GRAPH.001, showing axis formatting.
Page 5
3. Some quick demonstrations
==============================
For a quick and easy demonstration of some of the graph
plotting capabilities of the programs follow the steps listed
below. You need a Fortran 77 compiler to compile the program.
The Fortran programs should be usable on any computer which
has a Fortran 77 compiler and a suitable dot matrix printer,
though this section assumes you are using an MS-Dos or PC-Dos
operating system (for the GRF.bat batch file).
The graphs should print correctly on printers such as the IBM
Proprinter, and most Epson and Star dot matrix printers. If
you have a different printer, try this procedure first. If the
graph does not print correctly then you will have to modify
subroutine PRTGRF in disk file GRAPHLIB.for. If you have less
than 310 kBytes of available RAM, you may have to change the
DIMENSION statement in the sample main program GRAPH.for; and
you may not have enough memory to print some the demonstration
graphs.
To print out GRAPH.001:
-----------------------
a) Insert the disk containing the GRAPH programs into the
default disk drive, or if you have a hard disk then copy
them to the hard disk.
b) Compile the program GRAPH.for using your Fortran 77
compiler. An executable file called GRAPH.exe should be
created by the compiler.
c) Make sure the dot matrix printer is connected and
switched on.
d) At the Dos command line type :
grf 001
e) Wait a minute or two while the graph is 'plotted' in the
computer's memory, after which it will be directed to the
printer and printed in high resolution.
The above procedure uses the supplied batch file GRF.bat to
print out the graph defined in the demonstration file
GRAPH.001. Several other graph demonstration files are
supplied on disk; these are named GRAPH.nnn, where nnn is a
number. Just type grf nnn to print graph GRAPH.nnn
(assuming that you have already compiled the sample main
program GRAPH.for).
Page 6
4. Using GRAPH to plot graphs from a data file
================================================
The simplest way to plot graphs on a dot matrix printer is to
create a data file, and use the GRF.bat batch file to execute
it. Remember to compile the GRAPH.for program before you try
to execute it, using a Fortran 77 compiler (as described in
Section 3).
The data file can be created using a word processor in non-
document mode, or it can be written by one of your own
programs as a simple ASCII data file. If you know how to
program in Fortran it should be a simple matter to tailor
GRAPH.for to your own requirements if necessary.
A graph data file is created for input to the program. The
program then 'plots' the graph in memory, as a matrix of
points, before directing it to the printer. The maximum size
graph which can be plotted from the program GRAPH.for is 20 x
25 cm, but this can easily be changed by changing the
DIMENSION statement in GRAPH.for. The program is rather memory
intensive - for example the 20 x 25 cm size requires at least
310 kBytes of RAM for Hi-res plotting (though only about 80
kBytes for Lo-res).
a) Plotting the demo graphs supplied
--------------------------------------
To get started, try plotting some or all of the demonstration
graphs supplied with the programs after you have compiled the
program GRAPH.for with your Fortran 77 compiler. The demo
graphs are named GRAPH.nnn, where the nnn refers to a number
from 000 to 999. For example, to plot the graph described by
file GRAPH.001, type :
grf 001
Make sure the printer is switched on. The graph will be
'plotted' in memory first, which could take a minute or two,
before being directed to the printer. Repeat this for all the
graph demos, so that you will have an idea of the capabilities
of the subroutines.
b) Plotting your own graphs
-----------------------------
To plot you own graphs from program GRAPH you will need to
create data files similar to the demo files described above.
Have a look at some of the demo files, and you will see that
they are simply lists of numbers and text. These provide the
program with information on the size and style of the graph,
and the data to be plotted. The program GRAPH.for reads the
data file, and passes the appropriate parameters to the
subroutines which do the plotting. It has been written very
simply, to make it easy for you to re-write to your own
requirements if you need to. As a result, the data
file is expected to be in a rigid format, so if you are going
to use the original GRAPH.for program, your data file must
conform to the specifications given in (c) below.
Page 7
c) Data file specifications for GRAPH.for :
--------------------------------------------
The data file to be read by the supplied sample main program
GRAPH.for must conform to the specifications listed below. A
detailed discussion of the demonstration data file GRAPH.001
is given in Appendix D. You can always re-write the main
program to put the data entry into a more convenient form for
your own applications. If you plan to use GRAPH.for for
plotting your own graphs then the data file you write must
conform to the following specifications:-
1. Maximum 80 characters per line (standard Fortran input).
2. Numbers must generally be within fields of width 10 columns,
(5 column width for the first line of each data set).
3. Text may occupy rest of line to column 80.
4. If more than 8 numbers are required, use as many lines as
necessary. (eg. for entering more than 8 function parameters)
The names used are defined in Appendix A.
Once you have read through them, most of them will be self-evident.
line 1 : glabel. {Graph title}
line 2 : xlabel. {x-axis title}
line 3 : ylabel. {y-axis title}
line 4 : xl, yl, bwleft, bwrght, bwtop, bwbott.
{x & y-axis lengths and border widths}
line 5 : xmin, xmax, ymin, ymax.
{min & max values for plotting}
line 6 : ndivx, nsdivx, igrdx1, igrdx2, ndpx
{x-axis specs, divisions, grid lines, dec. places}
line 7 : ndivy, nsdivy, igrdy1, igrdy2, ndpy
{y-axis specs, divisions, grid lines, dec. places}
line 8 : iszval, iszxyl, ioriyv, iszttl, justtl
{size, orientation, justification of axis labels}
line 9 : valpos, xlbpos, ylbpos, ttlpos
{for adjusting placing of axis labels}
line 10 : igrprt, ivh, lohi, ioff
{print control for axes, format, resolution, offset}
line 11 : lgdpos, lgdlns, lgdchs, lgdsiz, lgdtyp
{legend table specs - position, lines, chars, text size, line}
Next comes the data for each set of data to be plotted.
Each set of data can be one of...
a) Clearing a rectangular area of the graph, with optional border;
b) Write text at (x,y), with any size, orientation and justification;
c) Plot one of the continuous functions from subroutine GRAPHFNS
d) Plot a set of points, with optional straight lines or smooth curve
through the points.
Page 8
For each set of data add the following lines...
line a : npts, ltyp, mark, msize, inout, legend.
{Number of points or type of plot, line type etc.}
line b : if npts>0 [Plot a series of npts data points]
enter --- x, y (1 line for each data pair)
if npts=0 [Plot user-defined function number ifn]
enter --- 1st line: ifn, nparms, x1, x2
2nd line: p(i) for i=1 to nparms
if npts=-1 [ Write a text string starting at (x,y) ]
[ (x,y) defines the centre of upper case X ]
enter --- 1st line: iori, itxsiz, justif, x, y
2nd line: strng
if npts=-2 [ Clear a rectangular area of the graph ]
[ (x1,y1)=top left, (x2,y2)=bottom right ]
enter --- 1st line: x1, y1, x2, y2
if npts=-99 [ End of data. Plot graph and terminate program ]
Page 9
5. Using the GRAPHLIB subroutines to plot graphs from your own programs
========================================================================
It is a simple matter to get your own Fortran programs to
print graphs on dot matrix printers which have plotting
facilities. Read through sections 3 and 4 first to get an idea
of how the sample main program works. For you own program you
simply need to assign values to the variables described in the
above section (ie. the variables which are read from a data
file in the sample main program supplied). You also need to
DIMENSION the arrays IGRAPH and P in your main program
according to the maximum size graph you will be printing out,
and the maximum number of parameters to be passed to the user-
defined functions. Details are in the source code file
GRAPH.for. If you want to add your own user-defined functions,
you can do this by modifying the file GRAPHFNS.for. Then your
program calls the following subroutines :
PREP(... to prepare axis sizes, scaling factors, and other
details. This MUST be called before any of the plotting
routines.
AXES(... to define and plot axes for the graph.
PLOTD(...for each set of data to be plotted. A 'set of data'
is defined as a string of text, a user-defined
function plotted between specified values on the x-
axis, a set of data points (which may be connected
by a line or smooth curve), or clearing an area of
the graph.
If your program is to plot more than one graph, remember to
clear the previous graph before starting to plot the next one,
using :-
CLRGRF(...
Finally, you will also need to include the subroutine library
and function segment with the statements:
INCLUDE 'GRAPHLIB.for'
INCLUDE 'GRAPHFNS.for'
For more advanced programming or plotting, you may want to
call some of the other subroutines in the library, or you may
want to modify them for your personal use. The subroutines
should have sufficient comment lines to enable you to do this
if you are reasonably familiar with programming in Fortran.
Page 10
6. Limitations
================
a) Graph size & Memory
------------------------
The size of graph which you can plot is limited only by the
paper size on your printer, and the amount of memory (RAM)
available in your computer. The maximum size is set by the
DIMENSION statement for array IGRAPH in the main program. For
a graph of 20 x 25 cm (8" x 10"), about 310 kBytes of RAM is
required for Hi-res, and about 80 kB for Lo-res.
If the x- or y-axis lengths (plus the allocated border widths)
specified are too long for the DIMENSION'ed size of IGRAPH, the
program will terminate with an error.
b) Function parameters
------------------------
The maximum number of parameters which can be passed to the
user-defined functions in FUNCTION FGRAPH is specified by the
DIMENSION of array P() in the main program.
Page 11
Appendix A. Definition of Fortran names used
==============================================
Below is a list of the main variable names used in the program GRAPH
and subroutine library GRAPHLIB.
BWBOTT = Border width below axes, cm.
BWLEFT = Border width to left of axes, cm.
BWRGHT = Border width to right of axes, cm.
BWTOP = Border width above axes, cm.
GLABEL = Graph title.
IFN = Function number (pre-compiled in FUNCT) to plot if NPTS=0.
IGRDx1,x2,y1,y2 = 1 to n for grid lines of line type LTYP on major/minor
divisions of x and y-axes. 0 for no grid lines.
IGRPRT = 1 to print the axes, 0 to suppress printing of axes when calling
subroutine AXES. You need to call AXES to set XMIN etc, but may
want to suppress the actual plotting of the axes.
INOUT = 0 to restrict plotting to within axes,
1 to allow plotting into border areas.
IOFF = Offset. This number of blank spaces will be printed from the left
margin before the graph itself is printed.
IPT = Symbol to be plotted to mark a data point
1 : point
2 : open octagon
3 : filled "
4 : open square
5 : filled "
6 : open triangle
7 : filled "
8 : cross
9 : plus
10 : star
11 : open diamond
12 : filled "
13-31 : Might be used later. Blank for now.
32-126 : plot the corresponding ASCII character (Orientation = 1)
ISZTTL = The text size for printing the graph title
ISZVAL = The text size for printing axis values
ISZXYL = The text size for printing x and y-axis labels
ITXSIZ = Size of text to be plotted (1 to n). 2 = "normal".
Page 12
IVH = 1 for vertical (portrait) printout, 2 for horizontal (landscape).
JUSTIF = Text justification. -1=left, 0=centre, 1=right.
JUSTTL = Justification of graph title. (-1=left, 0=centre, 1=right)
LEGEND = Text to describe each data set. Blank to suppress.
LGDCHS = Max number of characters for an entry into the legend table
LGDLNS = Number of lines of text to be allocated for legend table
LGDPOS = Position of legend table. 1 = top left, to 4 = top right.
5 = bott. " , to 8 = bott. " .
LGDSIZ = Text size for legend table entries (for sizing the legend table)
LGDTYP = Line type to draw around legend table. (0=none, 1=solid etc)
LOHI = 1 for Low-res (quick) plot, 2 for Hi-Res.
LTYP = Line type : 0 = none
1 = continuous line
2 = .................
3 = . . . . . . . . .
4 = - - - - - - - - -
5 = -- . -- . -- . --
MARK = Symbol to be plotted at each point (see also IPT)
(1 = dot, 2..8 = symbol, 32..126 = ASCII character)
MAXX = Number of dots across x-axis. (calculated by PREP)
MAXY = Number of dots along y-axis. (calculated by PREP)
MMAXX = the number of columns of dots across the page,
MMAXX,MMAXY are for passing the dimension of IGRAPH to subroutines.
MMAXY = the (number of rows of dots)/14
MSIZE = Size of symbol to be plotted
NDIVX = No of major divisions along x-axis (0 for log. scales)
NDIVY = No of major divisions along y-axis (0 for log. scales)
NDPX = No of decimal places for axis values on x-axis. Ignored for log axes.
NDPY = No of decimal places for axis values on y-axis. Ignored for log axes.
NPARMS = Number of parameters to be passed to function IFN (max 100).
NPTS = No of data points for current data set, or if <=0 then..
0 to plot a function curve,
-1 for plotting a text string,
-2 to clear a rectangular area of the graph, with optional border.
Page 13
NSDIVX = No of secondary divisions between each major division on x-axis.
Use 1 or 9 for log. scales.
NSDIVY = No of secondary divisions between each major division on y-axis.
Use 1 or 9 for log. scales.
P = The array of parameters to be passed to function IFN.
STRNG = A string of text to be printed on the graph
TITLE = Graph title (also GLABEL).
TTLPOS = To adjust the distance between axis and centre of graph title.
(>0 = Above top axis, <0 = below bottom axis
magnitude: 1=default, <1=closer to axis, >1=further from axis)
VALPOS = To adjust the distance between axis and centre of axis value.
(1=default, <1=closer to axis, >1=further from axis)
X1,X2 = Start and end values of x for plotting function IFN.
XL = Length of x-axis, cm.
XLABEL = x-axis label.
XLBPOS = To adjust the distance between x-axis and x-axis label.
1=default, <1=closer to axis, >1=further from axis.
XMAX = Maximum value on x-axis
XMAX = x-value at extreme right of graph page
XMIN = Minimum value on x-axis
XMINA = x-value at extreme left of graph page
YL = Length of y-axis, cm.
YLABEL = y-axis label.
YLBPOS = As for XLBPOS, but for y-axis. eg. If IORIYV=1 and the y-axis
values are several characters long, set YLBPOS>1 to shift the
label further away from the axis.
YMAX = Maximum value on y-axis
YMAXA = y-value at top of graph page
YMIN = Minimum value on y-axis
YMINA = y-value at bottom of graph page
Page 14
Appendix B. Symbols and line types
====================================
When a set of data points is to be plotted, a symbol from
Table B1 is plotted at the position of each point. When points
are to be joined with lines, the type of line specified by
ltyp is shown below in Table B2. The symbols and lines can
best be seen by printing out the demonstration graph GRAPH.004
(see sections 3 and 4 for how to do this).
Table B1 : Symbols Table B2 : Line Types (approx)
-------------------- --------------------------------
mark:- ltyp:-
1 = point 1 = solid (continuous) line
2 = open octagon 2 = .................
3 = filled " 3 = . . . . . . . . .
4 = open square 4 = - - - - - - - - -
5 = filled " 5 = -- . -- . -- . --
6 = open triangle
7 = filled "
8 = cross
9 = plus
10 = star
11 = open diamond
12 = filled "
32 to 126 = point plus ASCII character, defined below:
ASCII Characters
==================
50 2 70 F 90 Z 110 n
51 3 71 G 91 [ 111 o
32 52 4 72 H 92 \ 112 p
33 ! 53 5 73 I 93 ] 113 q
34 " 54 6 74 J 94 ^ 114 r
35 # 55 7 75 K 95 _ 115 s
36 $ 56 8 76 L 96 ` 116 t
37 % 57 9 77 M 97 a 117 u
38 & 58 : 78 N 98 b 118 v
39 ' 59 ; 79 O 99 c 119 w
40 ( 60 < 80 P 100 d 120 x
41 ) 61 = 81 Q 101 e 121 y
42 * 62 > 82 R 102 f 122 z
43 + 63 ? 83 S 103 g 123 {
44 , 64 @ 84 T 104 h 124 |
45 - 65 A 85 U 105 i 125 }
46 . 66 B 86 V 106 j 126 ~
47 / 67 C 87 W 107 k
48 0 68 D 88 X 108 l
49 1 69 E 89 Y 109 m
Page 15
Appendix C. Sample list of standard user-defined functions
============================================================
You can plot any continuous function f(x) by calling one of
the functions defined in FUNCTION FGRAPH(..., supplied on disk
as file GRAPHFNS.for. A number of standard functions have
been supplied in this file to get you started. If you need any
others, just program them in the same manner, and re-compile
your program. The maximum number of parameters which can be
passed is specified in the DIMENSION of the array P() in the
main program segment (set at 20 in the sample main program
GRAPH.for).
The functions are called with a function number (to specify
which function you want to evaluate), a list of parameters,
and an x-value. It then returns the corresponding y-value. For
example, if you want to plot the parabola f(x) = 1.2 + 2*x -
3.4*x^2, you would specify :
IFN = 1 (function number 1 = polynomial)
P(1) = 2 (polynomial of order 2)
P(2) = 1.2 (1st coefficient of the polynomial)
P(3) = 2 (2nd " )
P(4) = 3.4 (3rd " )
The file GRAPHFNS.for is printed out below for convenience.
The standard functions available are :-
1. Polynomial of any order f(x) = a0 + a1.x + a2.x^2 + ... + an.x^n
2. Exponential f(x) = a + b.exp(c.x)
3. Power function f(x) = a + b*x^c
4. Logarithmic (natural) f(x) = a + b.ln(c.x+d)
5. Logarithmic (base 10) f(x) = a + b.log(c.x+d)
6. Inverse function f(x) = a + b/(c+x)
7. Circle (top or bottom half)
8. Ellipse (top or bottom half)
Page 16
This is a listing of the source code for the sample user-defined
functions supplied with the programs :-
FUNCTION FGRAPH(IFN,P,X)
*
* The list of functions for plotting on IGRAPH.
* This list can be added to as required.
*
* FNUM = Function number
* P = Array of parameters to be passed to the selected function
* X = X-value at which the function is to be evaluated
*
DIMENSION P(*)
* To add more functions, add labels to the following statement:
GOTO (1,2,3,4,5,6,7,8) IFN
*
* Function 1. Polynomial (to n-th order). n+2 parameters.
* P(1)=n, P(2) to P(n+2) = coeffecients a0, a1, a2, ... an.
* [ f(x) = a0 + a1.x + a2.x^2 + ... + an.x^n ]
*
1 N = INT(P(1)+0.5)
POLY = P(N+2)
DO 100 I=N+1, 2, -1
POLY = X*POLY + P(I)
100 CONTINUE
FGRAPH = POLY
RETURN
*
* Function 2. Exponential, 3 parameters.
* f(x) = a + b.exp(c.x)
*
2 FGRAPH = P(1) + P(2)*EXP(P(3)*X)
RETURN
*
* Function 3. Power function, 3 parameters.
* f(x) = a + b.x^c
*
3 FGRAPH = P(1) + P(2)*X**P(3)
RETURN
*
* Function 4. Logarithmic, 4 parameters.
* f(x) = a + b.ln(c.x+d)
*
4 FGRAPH = P(1) + P(2)*ALOG(P(3)*X + P(4))
RETURN
*
* Function 5. Base 10 Logarithmic, 4 parameters.
* f(x) = a + b.log(c.x+d)
*
5 FGRAPH = P(1) + P(2)*ALOG10(P(3)*X + P(4))
RETURN
*
* Function 6. Inverse function, 3 parameters.
* f(x) = a + b/(c+x)
6 FGRAPH = P(1) + P(2)/(P(3)+X)
RETURN
Page 17
*
* Function 7. Circle. 4 Parameters.
* P(1) = 1 for top half of circle, -1 for bottom half.
* P(2) = radius.
* P(3) = x coordinate of centre of circle.
* P(4) = y coordinate of centre of circle.
*
7 XXX = P(2)*P(2) - (X-P(3))**2.
IF(XXX.LT.0) XXX = 0.
FGRAPH = P(1)*SQRT(XXX) + P(4)
RETURN
*
* Function 8. Ellipse. 5 Parameters.
* P(1) = 1 for top half of ellipse, -1 for bottom half.
* P(2) = max radius in x direction.
* P(3) = max radius in y direction.
* P(4) = x coordinate of centre of ellipse.
* P(5) = y coordinate of centre of ellipse.
*
8 XXX = 1.- ((X-P(4))/P(2))**2.
IF(XXX.LT.0) XXX = 0.
FGRAPH = P(1)*P(3)*SQRT(XXX) + P(5)
RETURN
END
*---------------------------------------------------------------------------
Page 18
Appendix D. A sample data file for use with GRAPH
===================================================
Several demonstration graph files are supplied with the programs.
The first one, GRAPH.001, is discussed in detail in this section
to make it easier to understand how to set up your own graph data
files for use with the sample main program GRAPH.for. The actual
data file is :-
Demonstration Graph 1
x-axis, log scale
y-axis, linear scale
16. 12. 2. 1. 1. 2.
1 100 0. 10.
0 9 2 2 0
10 4 2 2 0
2 3 0 3 0
1. 1. 1. 1.
1 1 2 5
1 4 27 2 1
6 -1 2 2 0 Data 1, fitted with spline
1.33 2.1
1.67 4.4
2.67 6.3
10. 7.4
30. 8.
60. 9.2
6 1 3 2 0 Data 2, with straight lines
3. .3
8. 1.
15. .5
25. 1.5
50. 1.5
90. 4.
6 0 6 3 0 Data 3, points only
2. 1.5
6. 2.
10. 2.6
20. 3.7
45. 5.5
80. 9.3
0 4 1 1 0 y = x/10 + 1.5
1 3 1.5 90. {function 1. Polynomial}
1 1.5 0.1
-2 1 0 0 1
25. 4.7 53. 5.3
-1 1 0 0 1
1 2 -1 28. 5.
Any text
-99
Page 19
The data file is described below on a line-by-line basis...
------------------------------------------------------------
Demonstration Graph 1
---> line 1 : Graph title
x-axis, log scale
---> line 2 : x-axis label
y-axis, linear scale
---> line 3 : y-axis label
16. 12. 2. 1. 1. 2.
---> line 4 : xl, yl, bwleft, bwrght, bwtop, bwbott.
x,y axis lengths = 16 & 12 cm, with 2 cm. border left and below,
and 1 cm. border right and above.
1 100 0. 10.
---> line 5 : xmin, xmax, ymin, ymax.
x-axis runs from 1 to 100, y-axis from 0 to 10.
0 9 2 2 0
---> line 6 : ndivx, nsdivx, igrdx1, igrdx2, ndpx
x-axis has log scale, 9 secondary subdivisions between decades,
grid on major and minor axes in linestyle 2, 0 decimal places (ignored
for log axes).
10 4 2 2 0
---> line 7 : ndivy, nsdivy, igrdy1, igrdy2, ndpy
y-axis has linear scale with 10 major divisions, 4 secondary subdivisions
between major divisions, grid on major and minor axes in linestyle 2,
0 decimal places for values written along the axis.
2 3 0 3 0
---> line 8 : iszval, iszxyl, ioriyv, iszttl, justtl
text size 2 for axis values, text size 3 for axis titles (labels),
orientation 0 for y-axis values (ie. values are printed parallel to the
y-axis. Use 1 for parallel to x-axis), text size 3 for graph title,
0=centre justify graph title above top of graph.
1. 1. 1. 1.
---> line 9 : valpos, xlbpos, ylbpos, ttlpos
To adjust placing of text along axes: distance of axis values from axes,
distance of x and y titles from axes, distance of graph title above top
or below bottom of graph. Use 1. for default distance, <1 to shift closer
to axis, >1 to shift away from axes.
1 1 2 5
---> line 10 : igrprt, ivh, lohi, ioff
1=print axes (use 0 to define axis values but prevent actually printing
the axes), 1=vertical format (use 2 for horizontal), 2=Hi resolution,
print 5 spaces to offset graph from left of page.
1 4 27 2 1
---> line 11 : lgdpos, lgdlns, lgdchs, lgdsiz, lgdtyp
Put the legend table at position 1 (top left), allocate 4 lines of text
for the legend table, with up to 27 characters per line, legend text size
is to be 2, draw a box around legend table in line style 1 (solid line).
Page 20
----------Start first data set...
6 -1 2 2 0 Data 1, fitted with spline
---> npts=6, ltyp=-1, mark=2, msize=2, inout=0, legend='Data 1....
---> 6 points for data set 1, join points with a cubic spline (smooth curve),
place symbol 2 at each point (open octagon), size 2 for the symbol,
0 to restrict plotting to inside axes (use 1 to allow plotting outside
the axes, in the border areas), description for the legend table starting
in column 26.
1.33 2.1
1.67 4.4
2.67 6.3
10. 7.4
30. 8.
60. 9.2
---> The 6 data points for set 1 (x,y)
----------Start another data set...
6 1 3 2 0 Data 2, fitted with straight lines
---> 6 points for data set 2, 1=join points with straight lines of line style
1 (solid), place symbol 3 at each point (filled octagon), size 2 for
the symbol, restrict to inside axes, description for the legend table.
3. .3
8. 1.
15. .5
25. 1.5
50. 1.5
90. 4.
---> the 6 data points for set 2 (x,y)
----------Start another data set...
6 0 6 3 0 Data 3
---> 6 points for data set 3, plot points only (do not join), place symbol 6
at each point (open triangle), size 3 for the symbol, restrict to inside
axes, description for the legend table.
2. 1.5
6. 2.
10. 2.6
20. 3.7
45. 5.5
80. 9.3
---> the 6 data points for set 3 (x,y)
----------Start another data set...
0 4 1 1 0 y = x/10 + 1.5
---> npts=0, ltyp=4, mark=1, msize=1, legend='y = x/10....
---> a user-defined function for set 4, line style 4 (dashed), ignored,
ignored, restrict to inside axes, description for the legend table.
1 3 1.5 90. {function 1. Polynomial}
---> ifn=1, nparms=3, x1=1.5, x2=90
---> user-defined function number 1 = polynomial, 3 parameters to be passed,
plot from x=1.5 to x=90.
Page 21
1 1.5 0.1
---> The 3 parameters (--> y = 1 + 1.5*x + 0.1*x^2 )
----------Start another data set...
-2 1 0 0 1
---> npts=-2 to clear a box, ltyp=1 to draw a solid line around the box,
mark & msize ignored, inout=1 to allow printing outside axes,
legend=blank (no legend entry).
25. 4.7 53. 5.3
---> The coordinates of the box to be cleared: (25,4.7) and (53,5.3)
----------Start another data set...
-1 1 0 0 1
---> npts=-1 to plot a text string, line style 1 (solid), mark & msize
ignored, inout=1 to allow printing outside axes, no legend entry.
1 2 -1 28. 5.
---> iori=1 for normal orientation for the text string (parallel to x-axis),
itxsiz=2 for text size 2, justif=-1 for left justified, at (28,5).
Any text
---> The text string to plot at the above conditions.
----------Start another data set...
-99
---> END OF DATA.
Page 22
Appendix E. Changes from earlier versions
===========================================
Version 2.0 : Addition of clearing an area of the graph, with optional
border around cleared area.
Minor changes to data entry format for GRAPH.
Version 3.0 : Simplified legend table box-drawing, to ensure grid lines
are cleared from the legend table.
Control over size and position of axis values and labels.
Separate specification of grid lines for x and y-axes, and
for major and minor sub-divisions along axes.
Major changes to data entry format for GRAPH.